<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>用户答题操作记录管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			//$("#name").focus();
			$("#inputForm").validate({
				submitHandler: function(form){
					loading('正在提交，请稍等...');
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
		});
		function addRow(list, idx, tpl, row){
			$(list).append(Mustache.render(tpl, {
				idx: idx, delBtn: true, row: row
			}));
			$(list+idx).find("select").each(function(){
				$(this).val($(this).attr("data-value"));
			});
			$(list+idx).find("input[type='checkbox'], input[type='radio']").each(function(){
				var ss = $(this).attr("data-value").split(',');
				for (var i=0; i<ss.length; i++){
					if($(this).val() == ss[i]){
						$(this).attr("checked","checked");
					}
				}
			});
		}
		function delRow(obj, prefix){
			var id = $(prefix+"_id");
			var delFlag = $(prefix+"_delFlag");
			if (id.val() == ""){
				$(obj).parent().parent().remove();
			}else if(delFlag.val() == "0"){
				delFlag.val("1");
				$(obj).html("&divide;").attr("title", "撤销删除");
				$(obj).parent().parent().addClass("error");
			}else if(delFlag.val() == "1"){
				delFlag.val("0");
				$(obj).html("&times;").attr("title", "删除");
				$(obj).parent().parent().removeClass("error");
			}
		}
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li><a href="${ctx}/brain/bUserOrprInfo/">用户答题操作记录列表</a></li>
		<li class="active"><a href="${ctx}/brain/bUserOrprInfo/form?id=${bUserOrprInfo.id}">用户答题操作记录<shiro:hasPermission name="brain:bUserOrprInfo:edit">${not empty bUserOrprInfo.id?'修改':'添加'}</shiro:hasPermission><shiro:lacksPermission name="brain:bUserOrprInfo:edit">查看</shiro:lacksPermission></a></li>
	</ul><br/>
	<form:form id="inputForm" modelAttribute="bUserOrprInfo" action="${ctx}/brain/bUserOrprInfo/save" method="post" class="form-horizontal">
		<form:hidden path="id"/>
		<sys:message content="${message}"/>		
		<div class="control-group">
			<label class="control-label">user_id：</label>
			<div class="controls">
				<sys:treeselect id="user" name="user.id" value="${bUserOrprInfo.user.id}" labelName="user.name" labelValue="${bUserOrprInfo.user.name}"
					title="用户" url="/sys/office/treeData?type=3" cssClass="" allowClear="true" notAllowSelectParent="true"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">user_name：</label>
			<div class="controls">
				<form:input path="userName" htmlEscape="false" maxlength="255" class="input-xlarge "/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">耗时 精确到秒：</label>
			<div class="controls">
				<input name="useagetime" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate "
					value="<fmt:formatDate value="${bUserOrprInfo.useagetime}" pattern="yyyy-MM-dd HH:mm:ss"/>"
					onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false});"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">总得分：</label>
			<div class="controls">
				<form:input path="score" htmlEscape="false" maxlength="5" class="input-xlarge  digits"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">错题数：</label>
			<div class="controls">
				<form:input path="incorrect" htmlEscape="false" maxlength="5" class="input-xlarge  digits"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">对题数：</label>
			<div class="controls">
				<form:input path="correct" htmlEscape="false" maxlength="5" class="input-xlarge  digits"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">是否全对, 0否 1是：</label>
			<div class="controls">
				<form:input path="allcorrected" htmlEscape="false" maxlength="1" class="input-xlarge "/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">是否全错, 0否 1是：</label>
			<div class="controls">
				<form:input path="allincorrected" htmlEscape="false" maxlength="1" class="input-xlarge "/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">是否通过 0否 1是：</label>
			<div class="controls">
				<form:input path="iscross" htmlEscape="false" maxlength="1" class="input-xlarge "/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">用户当前星级：</label>
			<div class="controls">
				<form:input path="userCurrentStar" htmlEscape="false" maxlength="6" class="input-xlarge  digits"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">答题开始时间：</label>
			<div class="controls">
				<input name="answerStarttime" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate "
					value="<fmt:formatDate value="${bUserOrprInfo.answerStarttime}" pattern="yyyy-MM-dd HH:mm:ss"/>"
					onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false});"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">比赛类型  001 排位赛,002练习赛：</label>
			<div class="controls">
				<form:input path="praticeType" htmlEscape="false" maxlength="255" class="input-xlarge "/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">当天第几局：</label>
			<div class="controls">
				<form:input path="praticeSortToday" htmlEscape="false" maxlength="6" class="input-xlarge  digits"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">当天 基于类型的第几局：</label>
			<div class="controls">
				<form:input path="particeType SortToday" htmlEscape="false" maxlength="6" class="input-xlarge  digits"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">租户ID：</label>
			<div class="controls">
				<form:input path="tenantId" htmlEscape="false" maxlength="64" class="input-xlarge "/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">题目总数：</label>
			<div class="controls">
				<form:input path="execriCount" htmlEscape="false" maxlength="3" class="input-xlarge  digits"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">临界分数：</label>
			<div class="controls">
				<form:input path="criticalScore" htmlEscape="false" maxlength="6" class="input-xlarge  digits"/>
			</div>
		</div>
			<div class="control-group">
				<label class="control-label">b_oper_record_detial：</label>
				<div class="controls">
					<table id="contentTable" class="table table-striped table-bordered table-condensed">
						<thead>
							<tr>
								<th class="hide"></th>
								<th>题干</th>
								<th>题目ID</th>
								<th>题型</th>
								<th>耗时</th>
								<th>得分</th>
								<th>是否正确 0 否 1是</th>
								<th>答案</th>
								<th>答案ID</th>
								<shiro:hasPermission name="brain:bUserOrprInfo:edit"><th width="10">&nbsp;</th></shiro:hasPermission>
							</tr>
						</thead>
						<tbody id="bOperRecordDetialList">
						</tbody>
						<shiro:hasPermission name="brain:bUserOrprInfo:edit"><tfoot>
							<tr><td colspan="10"><a href="javascript:" onclick="addRow('#bOperRecordDetialList', bOperRecordDetialRowIdx, bOperRecordDetialTpl);bOperRecordDetialRowIdx = bOperRecordDetialRowIdx + 1;" class="btn">新增</a></td></tr>
						</tfoot></shiro:hasPermission>
					</table>
					<script type="text/template" id="bOperRecordDetialTpl">//<!--
						<tr id="bOperRecordDetialList{{idx}}">
							<td class="hide">
								<input id="bOperRecordDetialList{{idx}}_id" name="bOperRecordDetialList[{{idx}}].id" type="hidden" value="{{row.id}}"/>
								<input id="bOperRecordDetialList{{idx}}_delFlag" name="bOperRecordDetialList[{{idx}}].delFlag" type="hidden" value="0"/>
							</td>
							<td>
								<input id="bOperRecordDetialList{{idx}}_stem" name="bOperRecordDetialList[{{idx}}].stem" type="text" value="{{row.stem}}" maxlength="255" class="input-small "/>
							</td>
							<td>
								<input id="bOperRecordDetialList{{idx}}_exerciseId" name="bOperRecordDetialList[{{idx}}].exerciseId" type="text" value="{{row.exerciseId}}" maxlength="64" class="input-small "/>
							</td>
							<td>
								<input id="bOperRecordDetialList{{idx}}_exercType" name="bOperRecordDetialList[{{idx}}].exercType" type="text" value="{{row.exercType}}" maxlength="255" class="input-small "/>
							</td>
							<td>
								<input id="bOperRecordDetialList{{idx}}_useage" name="bOperRecordDetialList[{{idx}}].useage" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate "
									value="{{row.useage}}" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false});"/>
							</td>
							<td>
								<input id="bOperRecordDetialList{{idx}}_score" name="bOperRecordDetialList[{{idx}}].score" type="text" value="{{row.score}}" maxlength="6" class="input-small  digits"/>
							</td>
							<td>
								<input id="bOperRecordDetialList{{idx}}_iscorrect" name="bOperRecordDetialList[{{idx}}].iscorrect" type="text" value="{{row.iscorrect}}" maxlength="1" class="input-small "/>
							</td>
							<td>
								<input id="bOperRecordDetialList{{idx}}_answer" name="bOperRecordDetialList[{{idx}}].answer" type="text" value="{{row.answer}}" maxlength="255" class="input-small "/>
							</td>
							<td>
								<input id="bOperRecordDetialList{{idx}}_answerId" name="bOperRecordDetialList[{{idx}}].answerId" type="text" value="{{row.answerId}}" maxlength="64" class="input-small "/>
							</td>
							<shiro:hasPermission name="brain:bUserOrprInfo:edit"><td class="text-center" width="10">
								{{#delBtn}}<span class="close" onclick="delRow(this, '#bOperRecordDetialList{{idx}}')" title="删除">&times;</span>{{/delBtn}}
							</td></shiro:hasPermission>
						</tr>//-->
					</script>
					<script type="text/javascript">
						var bOperRecordDetialRowIdx = 0, bOperRecordDetialTpl = $("#bOperRecordDetialTpl").html().replace(/(\/\/\<!\-\-)|(\/\/\-\->)/g,"");
						$(document).ready(function() {
							var data = ${fns:toJson(bUserOrprInfo.bOperRecordDetialList)};
							for (var i=0; i<data.length; i++){
								addRow('#bOperRecordDetialList', bOperRecordDetialRowIdx, bOperRecordDetialTpl, data[i]);
								bOperRecordDetialRowIdx = bOperRecordDetialRowIdx + 1;
							}
						});
					</script>
				</div>
			</div>
		<div class="form-actions">
			<shiro:hasPermission name="brain:bUserOrprInfo:edit"><input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;</shiro:hasPermission>
			<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
		</div>
	</form:form>
</body>
</html>